home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14019 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: Miljenko Cvjetko <cvjetko@rt.e-technik.uni-erlangen.de>
  3. Newsgroups: comp.lang.c++,comp.lang.c++.moderated,comp.sys.hp.hpux
  4. Subject: Re: [Q] gcc 2.7.2 + STL + HP_UX 9.05 = memory_leak ?
  5. Date: 28 Mar 1996 13:12:56 -0000
  6. Organization: Regionales Rechenzentrum Erlangen, Germany
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4je38o$mdj@netlab.cs.rpi.edu>
  10. References: <4j66lu$olu@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: Thu, 28 Mar 1996 10:35:12 +0100
  13.  
  14. On 25 Mar 1996, Miljenko Cvjetko wrote:
  15.  
  16. > I was testing storing ptrs in STL container when I found
  17. > out a memory-leak in STL implementation in following 
  18. > example:
  19. > # include <list.h>           // STL list
  20. > # include <stdlib.h>
  21. > class X
  22. > {
  23. >  protected:
  24. >   list<int> nodes_;  // this line causes 
  25. >                      // memory leak problems!!!
  26. >                      //     under HP_UX 9.05
  27. >                      // not under Borland C/C++ + DOS
  28. > };
  29. > void f()
  30. > {
  31. >  X x1;
  32. > }
  33. > int main()
  34. > {
  35. >  memorymap(1);
  36. >  f();
  37. >  memorymap(1);   // list is out of scope 
  38. >  return 0;
  39. > }
  40. > - ------------------------------------------
  41. > Result:
  42. > arenastart               :          0
  43. > arenaend                 :          0
  44. > # of blocks              :          0
  45. > # of free blocks         :          0
  46. > # of used blocks         :          0
  47. > # of smblk blks          :          0
  48. > total space used         :          0
  49. > space in free blocks     :          0
  50. > space in used blocks     :          0
  51. > space in smblk blocks    :          0
  52. > 1073748164: node block 8192
  53. > 1073756356: free 1848
  54. > arenastart               : 1073748164
  55. > arenaend                 : 1073758204
  56. > # of blocks              :          2
  57. > # of free blocks         :          1
  58. > # of used blocks         :          1
  59. > # of smblk blks          :          0
  60. > total space used         :      10040
  61. > space in free blocks     :       1848
  62. > space in used blocks     :       8192
  63. > space in smblk blocks    :          0
  64. > - -------------------------------------------
  65. > In addition, this code was compiled under
  66. > BC 4.5 and had no memory leak! Am I
  67. > misinterpreting memorymap() function call?
  68. > Same was with some other containers (set,vector).
  69. > Any suggestions?
  70. > Thanx in advance
  71. > Regards 
  72. > m.
  73.  
  74. I got an answer and suggestion from James Kanze and he had right, 
  75. suspected block was some sort of pseudo-static allocation by the 
  76. implementation and it wasn't ever freed, and the number of the unfreed
  77. blocks didn't increase, when tested in a loop.
  78.  
  79. Thanx a lot James
  80.  
  81. Regards
  82.  
  83. miljenko
  84.  
  85.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  86.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  87.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  88.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  89.